import requests

'''
    对增删改查接口进行封装
'''


class IhrmEmpCURD(object):

    # 新增员工
    @classmethod
    def add_emp(cls, headers, data):
        url = " http://ihrm-java.itheima.net/api/sys/user"
        resp = requests.post(url=url, headers=headers, json=data)
        return resp

    # 删除员工
    @classmethod
    def del_emp(cls, emp_id, headers):
        url = " http://ihrm-java.itheima.net/api/sys/user/{}".format(emp_id)
        resp = requests.delete(url=url, headers=headers)
        return resp

    # 修改员工
    @classmethod
    def modify_emp(cls, emp_id, headers, data):
        url = " http://ihrm-java.itheima.net/api/sys/user/{}".format(emp_id)
        resp = requests.post(url=url, headers=headers, json=data)
        return resp

    # 查询员工
    @classmethod
    def query_emp(cls, emp_id, headers):
        url = " http://ihrm-java.itheima.net/api/sys/user/{}".format(emp_id)
        resp = requests.get(url=url, headers=headers)
        return resp


if __name__ == '__main__':

    headers = {"Authorization": "Bearer 9ac505ef-0a4a-4ae0-9851-487245afc8c1"}
    resp = IhrmEmpCURD().query_emp(1063705989926227968, headers)
    print(resp.json())
